#ifndef ADVANCEDDIALOG_H
#define ADVANCEDDIALOG_H

#include <QDialog>
#include <QTableWidget>
#include <QPushButton>
#include <QCheckBox>
#include <QLineEdit>
#include <QTabWidget>

class AdvancedDialog : public QDialog {
    Q_OBJECT
public:
    explicit AdvancedDialog(QWidget *parent = nullptr);
    enum IpMode { DHCP, Manual };
    void setIpMode(IpMode mode);
    void setIpList(const QList<QPair<QString, QString>> &list);
    void setGatewayList(const QList<QPair<QString, int>> &list);
    // 获取设置结果接口，可扩展
    QList<QPair<QString, QString>> getIpList() const;
    QList<QPair<QString, int>> getGatewayList() const;
    bool isAutoMetric() const;
    int getInterfaceMetric() const;
private slots:
    void onAddIp();
    void onEditIp();
    void onDeleteIp();
    void onAddGateway();
    void onEditGateway();
    void onDeleteGateway();
    void onAutoMetricToggled(bool checked);
private:
    void setupUi();
    void refreshIpTable();
    void refreshGatewayTable();
    QTabWidget *tabWidget;
    // IP设置Tab
    QWidget *ipTab;
    QTableWidget *ipTable;
    QPushButton *btnAddIp;
    QPushButton *btnEditIp;
    QPushButton *btnDeleteIp;
    QTableWidget *gatewayTable;
    QPushButton *btnAddGateway;
    QPushButton *btnEditGateway;
    QPushButton *btnDeleteGateway;
    QCheckBox *checkAutoMetric;
    QLineEdit *editMetric;
    // 数据
    QList<QPair<QString, QString>> ipList; // IP, Mask
    QList<QPair<QString, int>> gatewayList; // Gateway, Metric
    bool autoMetric = true;
    int interfaceMetric = -1;
    IpMode ipMode = Manual;
};

#endif // ADVANCEDDIALOG_H 